/**
 * 
 */

package com.chengyu.eyc.utils;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;

import com.chengyu.eyc.mapper.EycOrderMapper;

import cn.hutool.core.date.DateUtil;

/**
 * @author kevin
 *
 */
public final class SeqNumUtil {

    /**
     * 生成10位订单号
     * 
     * @return
     */
    public static String genOrderNum() {
        String key = DateUtil.format(new Date(), "yyMMdd");
        return String.join(Strings.EMPTY,key, StringUtils.leftPad(SpringUtil.getBean(EycOrderMapper.class).getSeqNum(key, "ORDER_NUM"), 4, "0"));
    }
    public static String genCouponNum() {
        String key = DateUtil.format(new Date(), "yyMMdd");
        return String.join(Strings.EMPTY,"NUC",key, StringUtils.leftPad(SpringUtil.getBean(EycOrderMapper.class).getSeqNum(key, "COUPON_NUM"), 4, "0"));
    }

    private SeqNumUtil() {}

}
